package com.demo.boss.models;

import com.demo.boss.common.enums.SysCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private Integer code;
    private String msg;
    private Object data;
    public static Result ok(){
        Result result = new Result();
        result.setCode(200);
        result.setMsg("请求成功");
        result.setData("");
        return result;
    }
    public static Result ok(Object data){
        Result result = new Result();
        result.setCode(200);
        result.setMsg("请求成功");
        result.setData(data);
        return result;
    }
    public static Result fail(SysCode sysCode){
        Result result = new Result();
        result.setCode(sysCode.getCode());
        result.setMsg(sysCode.getText());
        result.setData(null);
        return result;
    }
}
